<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="/includes.jsp"%>

<jsp:useBean id="durationHours" class="java.util.Date"/>
<jsp:useBean id="durationMins" class="java.util.Date"/>

<div class="layout">

    <h2>Person Summary</h2>
    <table class="styled" cellspacing="0">
        <tr>
            <th class="styled">Person</th>
            <th class="styled">Time</th>
            <th class="styled">Graphical</th>            
        </tr>
        <logic:iterate name="personTimeDTO" id="row">
            <jsp:setProperty name="durationHours" property="time" value="<%=((PersonTimeDTO)row).getDuration()/3600000L%>"/>
            <jsp:setProperty name="durationMins" property="time" value="<%=(((PersonTimeDTO)row).getDuration()/60000L)%60L%>"/>
            <tr>
                <td class="styled">
                    <beans:write name="row" property="string"/>
                </td>
                <td class="styled">
                    <beans:write name="durationHours" property="time" format="##"/>h:<beans:write name="durationMins" property="time" format="00"/>m
                </td>
                <td class="styled">
                    <div class="histogram" style="width: <beans:write name="row" property="percent"/>%">&nbsp;</div>
                </td>
            </tr>
        </logic:iterate>
    </table>
    
    <logic:iterate name="timeReportDTO" property="summaries" id="summary" indexId="i">
        <logic:equal name="i" value="1">
            <h2><beans:write name="summary" property="name"/> Summary</h2>
            <table class="styled" cellspacing="0">
                <tr>
                    <th class="styled"><beans:write name="summary" property="name"/></th>
                    <logic:iterate name="timeReportDTO" property="colNames" id="name">
                        <th class="styled"><beans:write name="name"/></th>
                    </logic:iterate>
                </tr>
                <logic:iterate name="summary" property="rows" id="row">
                    <tr>
                        <td class="styled"><beans:write name="row" property="name"/></td>
                        <logic:iterate name="row" property="longPercents" id="duration">
                            <jsp:setProperty name="durationHours" property="time" value="<%=((TimeSummaryTable.Row.LongPercent)duration).getLong()/3600000L%>"/>
                            <jsp:setProperty name="durationMins" property="time" value="<%=(((TimeSummaryTable.Row.LongPercent)duration).getLong()/60000L)%60L%>"/>
                            <td class="styled">
                                <logic:notEqual name="duration" property="long" value="0">
                                    <div class="histogram" style="width: <beans:write name="duration" property="percent"/>%">
                                        <beans:write name="durationHours" property="time" format="##"/>h:<beans:write name="durationMins" property="time" format="00"/>m
                                    </div>
                                </logic:notEqual>
                                <logic:equal name="duration" property="long" value="0">&nbsp;</logic:equal>
                            </td>
                        </logic:iterate>
                    </tr>
                </logic:iterate>
            </table>
        </logic:equal>
    </logic:iterate>

</div>